#
# wm independent hotkeys
#

# terminal emulator
super + Return
    alacritty
    #gnome-terminal

# program launcher
super + space
    rofi -show drun
	#rofi -show drun -lines 3 -eh 2 -bw 0 -width 100 -padding 400 -fullscreen

# make sxhkd reload its configuration files:
super + Escape
    pkill -USR1 -x sxhkd

#
# bspwm hotkeys
#

# quit bspwm normally
super + shift + Escape
    bspc quit

# close and kill, i.e. kill all terms
super + {_,shift + }w
    bspc node -{c,k}

# alternate between the tiled and monocle layout
super + m
    bspc desktop -l next

# if the current node is automatic, send it to the last manual, otherwise pull the last leaf
#alt + y
#    bspc query -N -n focused.automatic && bspc node -n last.!automatic || bspc node last.leaf -n focused

# swap the current node and the biggest node
super + g
    bspc node -s biggest

#
# state/flags
#

# set the window state
super + {t,ctrl + t,s,f}
    bspc node -t {tiled,pseudo_tiled,floating,fullscreen}

# set the node flags
#alt + ctrl + {x,y,z}
#    bspc node -g {locked,sticky,private}

#
# focus/swap
#

# focus the node in the given direction
#alt + {_,shift + }{h,j,k,l}
#    bspc node -{f,s} {west,south,north,east}

# focus the node for the given path jump
#alt + {p,b,comma,period}
#bspc node -f @{parent,brother,first,second}

# Circulate the leaves of the tree
super + {comma,period}
  bspc node @/ --circulate {backward,forward}

# Flip the layout vertically/horizontally
super + ctrl + {comma, period}
  bspc node @/ --flip {vertical,horizontal}

# Rotate desktop
super + {_,ctrl +}r
  bspc node @/ --rotate {90,-90}

# focus the next/previous node, cycles through all
super + {_,shift + }c
    bspc node -f {next,prev}

# focus the next/previous desktop
#alt + bracket{left,right}
#    bspc desktop -f {prev,next}

# focus the next/previous node only in current desktop
super + {_,shift + } Tab
    bspc node -f {next,prev}.local

# focus the last node/desktop
#alt + {grave,Tab}
#    bspc {node,desktop} -f last

# focus the older or newer node in the focus history
#alt + {o,i}
#    bspc wm -h off; \
#    bspc node {older,newer} -f; \
#    bspc wm -h on

# focus or send to the given desktop
super + {_,ctrl + }{1-9,0}
    bspc {desktop -f,node -d} '^{1-9,10}'
    # Example to show you can use their names instead
    #bspc {desktop -f,node -d} {web,term,code,chat,music,6,7}

#
# preselect
#

# preselect the direction
super + ctrl + {h,j,k,l}
    bspc node -p {west,south,north,east}

# preselect the ratio
super + ctrl + {1-9}
    bspc node -o 0.{1-9}

# cancel the preselection for the focused node
super + ctrl + space
    bspc node -p cancel

# cancel the preselection for the focused desktop
super + ctrl + shift + space
    bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel

#
# move/resize
#

# expand a window by moving one of its side outward
super + {h,j,k,l}
    ~/.config/sxhkd/bspwm_resize {west,south,north,east} 20
    #bspc node --edge {left -10,down +10,up -10,right +10}
    #bspc node -z {left -10 0,bottom 0 10,top 0 -10,right 10 0}
    #bspc window -e {left -10,down +10,up -10,right +10}

# contract a window by moving one of its side inward
super + shift + {h,j,k,l}
    bspc node --edge {right -10,up +10,down -10,left +10}
    #bspc node -z {right -10 0,up 0 10,bottom 0 -10,left 20 0}
    #bspc window -e {right -10,up +10,down -10,left +10}

# move a floating window
super + {Left,Down,Up,Right}
  bspc node -v {-20 0,0 20,0 -20,20 0}


##########################
#System
##########################

# Raises volume
#XF86AudioRaiseVolume
#  amixer set Master 2%+

# Lowers volume
#XF86AudioLowerVolume
#  amixer set Master 2%-

{XF86AudioLowerVolume,XF86AudioRaiseVolume}
  amixer set Master 5%{-,+} unmute

# Mutes
XF86AudioMute
  amixer set Master toggle

# Brightness goes up
XF86MonBrightnessUp 
  light -A 5 && notify-send 'brightness up'

# Brightness goes down
XF86MonBrightnessDown
  light -U 5 && notify-send 'brightness down'

# Microphone mute
XF86AudioMicMute
  amixer set Capture toggle

# Screen lock
XF86ScreenSaver
  lock

# Turns off laptop
XF86Launch1
  notify-send 'key pressed'
#  systemctl poweroff
